<template>
	<view class="main">
		<uni-nav-bar left-icon="left" @clickLeft="back()" title="异常申诉列表" background-color="#007AFF" color="#000"
			statusBar="true"></uni-nav-bar>

		<scroll-view class="scrollView" scroll-y="true" @scrolltolower="handleScrolltolowerone()"
			:style="{height: setcollapseheight() + 'px'}">
			<view class="orderBox" v-for="(item,index) in dataList">
				<view class="orderTitle">
					<span class="one">{{index+1}}</span>
					<span class="two">异常问题名称：{{item.abnormalName}}</span>
				</view>
				<view class="itemBox" @click="GotoDetail(item)">
					<view class="itemContent">
						<view class="itemTitle">状态:</view>
						<view class="itemValue">{{item.abnormalStatus===1?'已处理':'待处理'}}</view>
					</view>
					<view class="itemContent">
						<view class="itemTitle">创建时间:</view>
						<view class="itemValue">{{item.applyDate}}</view>
					</view>
				</view>
			</view>
			<view class="btnBox">
				<view @click="add" class="addBtn">
					新建异常申诉
				</view>
			</view>
			<view v-if="!dataList.length">
				<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png">
				</u-empty>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import orderCenterApi from '@/api/socialized-servce/order-center/index.js'
	import abnormalOrderApi from '@/api/socialized-servce/order-center/abnormal-order.js'
	export default {
		components: {

		},
		data() {
			return {
				page: 1,
				size: 10,
				total: 0,
				totalPages: 0,
				loading: false,
				dataList: [],
				modalshow: false,
				modalTilte: '',
				ProjectOrderDetails:JSON.parse(uni.getStorageSync('ProjectOrderDetails'))  || {}
			}
		},
		onShow() {
			this.queryPageList()
		},
		mounted() {
			this.setcollapseheight()
			// this.queryPageList()
		},
		methods: {
			add() {
				let url = '/pages/socialized-service/order-center/abnormal-order-add'
				this.$togo(url)
			},

			GotoDetail(e) {
				let params = {
					data: JSON.stringify(e)
				}
				let url = '/pages/socialized-service/order-center/abnormal-order-deatil'
				this.$togo(url,params)
			},
			async queryPageList() {
				if (this.loading) return
				this.loading = true
				let params = {
					page: this.page,
					size: this.size,
					condition: {
						projectNo: this.ProjectOrderDetails.projectNo,
						executeNo: this.ProjectOrderDetails.executeNo,
						providerNo: uni.getStorageSync('providerNo'),
						organizationNo: uni.getStorageSync('organizationNo'),
						abnormalType: 2
					}
				}
				uni.showLoading({
					title: '加载中...'
				});
				let res = await abnormalOrderApi.queryPageByCondition(params)
				uni.hideLoading();
				if (res.code === 200) {
					this.total = res.data.totalElements
					this.totalPages = res.data.totalPages
					let newList = res.data.content
					if (this.page === 1) {
						this.dataList = newList
					} else {
						this.dataList = [...this.dataList, ...newList]
					}
					// this.dataList.forEach(el=>{
					// 	if(el.brief !== null) {
					// 		el.brief = el.brief.split(';')
					// 	}
					// })
					this.loading = false
				}
			},
			setcollapseheight() {
				let topheightone = uni.upx2px(36)
				let winHeight = 0
				uni.getSystemInfo({
					success: function(res) {
						winHeight = res.windowHeight
					}
				});
				let oldHeight = uni.upx2px(56)

				winHeight = parseInt(winHeight) - topheightone - oldHeight
				// #ifndef H5
				winHeight = winHeight - 20

				// #endif
				return winHeight
			},
			handleScrolltolowerone() {
				if (this.loading) return;
				console.log('触底', this.page, this.totalPages);
				if (this.page <= this.totalPages && this.page * 10 < this.total) {
					this.page++
					this.queryPageList()
				}
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			}
		}

	}
</script>

<style lang="scss" scoped>
	.scrollView {
		// padding-top: 20rpx;
		padding: 20rpx 0rpx 140rpx;
		box-sizing: border-box;

		.content {
			width: 100%;
			color: #000;

			.item {
				position: relative;
				padding: 0 40rpx;
				font-size: 28rpx;
				margin-bottom: 20rpx;

				.dot {
					position: absolute;
					top: 60rpx;
					right: 52rpx;
					width: 16rpx;
					height: 16rpx;
					border-radius: 50%;
					background-color: red;
					z-index: 999;
				}

				.img {
					position: absolute;
					top: 66rpx;
					right: 60rpx;
					width: 34rpx;
				}

				.title {
					padding-bottom: 10rpx;
					border-bottom: 2rpx solid #c7c7c9;
					color: #91743E;
				}

				.brief {
					.brief-item {
						width: 100%;
					}
				}

				.sendTime {
					width: 100%;
					text-align: center;
					margin-bottom: 10rpx;
					color: #c7c7c9;
				}

				.container {
					padding: 22rpx;
					background: #FFFFFF;
					box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.05);
					border-radius: 10rpx 10rpx 10rpx 10rpx;

					.title {
						display: flex;
						font-weight: 700;
						overflow: hidden;
						font-size: 32rpx;
					}

					.brief {
						margin-top: 20rpx;
					}

					.times {
						margin-top: 26rpx;
						font-size: 28rpx;
						color: #606060;
					}
				}
			}

		}
	}

	.noData {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translateX(-50%) translateY(-50%);
		width: 100%;

		.img {
			width: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 166rpx;
				height: 153rpx;
			}

			.tex {
				font-size: 32rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #525252;
			}
		}

	}


	.orderBox {
		width: 684rpx;
		min-height: 60rpx;
		background-color: #ffffff;
		padding: 12rpx 14rpx 20rpx;
		box-sizing: border-box;
		margin: 0rpx auto;
		margin-top: 30rpx;
		left: 0rpx;
		top: 0rpx;
		width: 684rpx;
		opacity: 1;
		border-radius: 16rpx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0rpx 0rpx 12rpx rgba(0, 0, 0, 0.05);
		
		&:first-child {
			margin-top: 0;
		}

		.orderTitle {
			height: 42rpx;
			font-size: 26rpx;
			font-weight: bold;
			letter-spacing: 0rpx;
			line-height: 42rpx;
			color: rgba(39, 39, 39, 1);
			text-align: left;
			display: flex;
			justify-content: space-between;

			.one {
				margin-left: 10rpx;
			}

			.two {
				width: calc(100% - 40rpx);
			}

			.three {
				width: 100rpx;
				color: rgba(46, 205, 151, 1);
			}
		}

		.itemBox {
			margin: 10rpx auto 0rpx;
			width: 622rpx;
			min-height: 100rpx;
			opacity: 1;
			border-radius: 10rpx;
			background: rgba(245, 246, 250, 1);
			padding: 12rpx 0rpx 12rpx 18rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.itemContent {
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;
				height: 60rpx;
				line-height: 60rpx;
				font-size: 28rpx;
				font-weight: 400;
				letter-spacing: 0rpx;
				color: rgba(39, 39, 39, 1);

			}

			.itemTitle {
				width: 200rpx;
			}

			.itemValue {
				width: 400rpx;
			}
		}
	}

	.btnBox {

		.addBtn {
			width: 180rpx;
			padding: 6rpx 20rpx;
			height: 60rpx;
			line-height: 60rpx;
			background: linear-gradient(27deg, #2F99FF 0%, #62B1FF 100%);
			box-shadow: 0rpx 0rpx 10rpx 2rpx #0082FF;
			color: #ffffff;
			border-radius: 40rpx;
			text-align: center;
			position: fixed;
			left: 50%;
			bottom: 80rpx;
			transform: translateX(-50%);
		}
	}
</style>